﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Collections;

namespace Update
{
    public class XmlProcess
    {
        public XmlProcess()
        {

        }
        public Hashtable hasXml = null;
        public void ProcessChildHeaders(XmlNode node, XmlNode child, string elementName, string find)
        {
            while (child != null)
            {
                if (child.Attributes.Count > 0)
                {
                    foreach (XmlAttribute attr in child.Attributes)
                    {
                        /*
                        string s0 = attr.OwnerElement.Name;
                        string s1 = attr.Name;
                        string s2 = attr.Value;
                        */
                        if (elementName == attr.OwnerElement.Name && attr.Value == find)
                        {
                            hasXml = new Hashtable();
                            // has.Add(attr.OwnerElement.Name, attr.Value);
                        }
                        //else
                        //    return;
                    }
                }
                if (child.FirstChild.NodeType == XmlNodeType.Element)
                {
                    ProcessChildHeaders(node, child.FirstChild, elementName, find);
                }
                else
                {
                    if (hasXml != null)
                    {
                        try
                        {
                            hasXml.Add(child.Name, child.InnerText);
                        }
                        catch (Exception)
                        {
                            return;
                        }
                        
                    }
                    string name = child.Name + " - " + child.InnerText;
                }
                child = child.NextSibling;
            }

            return;
        }
    }
}
